﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace HarveyNash.RefactoringAndCodeSmell.CodeSmell.DuplicatedCode
{
    public static class After
    {
        public static XmlElement CreateAddressElement(XmlDocument xmlDocument, Address address)
        {
            XmlElement element = xmlDocument.CreateElement("Address");
            element.SetAttributeNode(CreateAttribute(xmlDocument, "Number", address.Number));
            element.SetAttributeNode(CreateAttribute(xmlDocument, "Street", address.Street));
            element.SetAttributeNode(CreateAttribute(xmlDocument, "City", address.City));
            element.SetAttributeNode(CreateAttribute(xmlDocument, "Country", address.Country));

            return element;
        }

        private static XmlAttribute CreateAttribute(XmlDocument xmlDocument, string name, string value)
        {
            XmlAttribute attribute = xmlDocument.CreateAttribute(name);
            attribute.Value = value;
            return attribute;
        }
    }
}
